from django import forms
from django.contrib.auth.forms import AuthenticationForm
from .models import Cat, Site

class LoginForm(AuthenticationForm):
    username = forms.CharField(label="用户名", widget=forms.TextInput(attrs={
        'class': 'form-control',
        'placeholder': '请输入用户名'
    }))
    password = forms.CharField(label="密码", widget=forms.PasswordInput(attrs={
        'class': 'form-control',
        'placeholder': '请输入密码'
    }))

class CatForm(forms.ModelForm):
    # 获取所有收容所选项
    site_choices = Site.objects.values_list('siteid', 'sname')
    site_id = forms.ChoiceField(
        choices=site_choices,
        label='收容所',
        widget=forms.Select(attrs={'class': 'form-control'})
    )
    class Meta:
        model = Cat
        fields = ['cname', 'cgender', 'month', 'status', 'siteid', 'description']
        widgets = {
            'cname': forms.TextInput(attrs={'class': 'form-control'}),
            'cgender': forms.TextInput(attrs={'class': 'form-control'}),
            'month': forms.NumberInput(attrs={'class': 'form-control'}),
            'status': forms.TextInput(attrs={'class': 'form-control'}),
            'siteid': forms.NumberInput(attrs={'class': 'form-control'}),
            'description': forms.TextInput(attrs={'class': 'form-control'}),
        }